﻿Public Class cls_list

    Dim i As Integer = 0
    Public List As System.ComponentModel.BindingList(Of rcd_sekolah)

    Public Sub New()
        List = New System.ComponentModel.BindingList(Of rcd_sekolah)
    End Sub

    Public Sub Add(ByVal index As Integer, ByVal kode As String, ByVal nama As String, ByVal kluster As Integer)
        List.Add(New rcd_sekolah(index, kode, nama, kluster))
    End Sub

    Public Sub Add(ByVal index As Integer, ByVal kode As String, ByVal nama As String, ByVal jurusan As String)
        List.Add(New rcd_sekolah(index, kode, nama, jurusan))
    End Sub

    Public Function getKode(ByVal nama As String) As String
        For Me.i = 0 To List.Count - 1
            If (List.Item(Me.i).Nama = nama) Then
                Return List.Item(Me.i).Kode
            End If
        Next

        Return "-1"
    End Function

    Public Function getKode(ByVal nama As String, ByVal jurusan As String) As String
        For Me.i = 0 To List.Count - 1
            If (List.Item(Me.i).Nama = nama And List.Item(Me.i).Jurusan = jurusan) Then
                Return List.Item(Me.i).Kode
            End If
        Next

        Return "-1"
    End Function

    Public Function getNama(ByVal kode As String) As String
        For Me.i = 0 To List.Count - 1
            If (List.Item(Me.i).Kode = kode) Then
                Return List.Item(Me.i).Nama
            End If
        Next

        Return "-1"
    End Function

    Public Function getKluster(ByVal Nama As String) As Integer
        For Me.i = 0 To List.Count - 1
            If (List.Item(Me.i).Nama = Nama) Then
                Return List.Item(Me.i).Kluster
            End If
        Next

        Return "-1"
    End Function

End Class


Public Class rcd_sekolah
    Private _index As Integer
    Private _kode As String
    Private _nama As String
    Private _jurusan As String
    Private _kluster As Integer

    Public Sub New(ByVal index As Integer, ByVal kode As String, ByVal nama As String, ByVal kluster As Integer)
        Me._kode = kode
        Me._nama = nama
        Me._kluster = kluster
    End Sub

    Public Sub New(ByVal index As Integer, ByVal kode As String, ByVal nama As String, ByVal jurusan As String)
        Me._index = index
        Me._kode = kode
        Me._nama = nama
        Me._jurusan = jurusan
    End Sub

    ReadOnly Property Index() As Integer
        Get
            Return Me._index
        End Get
    End Property

    ReadOnly Property Kode() As String
        Get
            Return Me._kode
        End Get
    End Property

    ReadOnly Property Nama() As String
        Get
            Return Me._nama
        End Get
    End Property

    ReadOnly Property Jurusan() As String
        Get
            Return Me._jurusan
        End Get
    End Property

    ReadOnly Property Kluster() As Integer
        Get
            Return Me._kluster
        End Get
    End Property

End Class